﻿hpxAdminApp.factory('wantBillService', ['Restangular', function (Restangular) {
    var res = Restangular.all('wantBill');
    return {
        getAllWantBill: function (params, filter) {
            var queryParam = {
                'p': params.page(),
                'n': params.count(),
                'orderBy': params.orderBy(),
                'bill_type_id': filter.billType,
                'min_face_price': filter.bill_sum_price_min,
                'max_face_price': filter.bill_sum_price_max,
                'min_dead_date': filter.min_dead_date,
                'max_dead_date': filter.max_dead_date,
                'acceptor_type_id': filter.acceptType,
                'bidding_mode': filter.biddingType,
                'status': filter.bill_status,
                'product_location_id': filter.product_location_id,
            }
            return res.get('userWantBills/list', queryParam).then(function (result) {
                params.total(result.page_info.items_number);
                return result.listName;
            });
        },
        addWantBill: function (model) {
            return res.all('userWantBills').customPOST(model);
        },
        editWantBill: function (model) {
            return res.all('userWantBills').one('list').customPUT(model);
        }
    }
}]);
